package org.tgcms.core.dal.appengine.domain;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.FetchGroup;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Version;
import javax.jdo.annotations.VersionStrategy;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.datanucleus.annotations.Unowned;

@PersistenceCapable(identityType=IdentityType.APPLICATION, detachable="true")
@Inheritance(customStrategy = "complete-table")
@Version(strategy = VersionStrategy.VERSION_NUMBER, column = "version", extensions = { @Extension(vendorName = "datanucleus", key = "field-name", value = "version") })
@FetchGroup(name = "all", members = { @Persistent(name = "parent") })
public class AppengineEntityBase {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

	protected Long version;

	@Persistent
	@Unowned
	protected AppengineEntityBase parent;

	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	public AppengineEntityBase getParent() {
		return parent;
	}

	public void setParent(AppengineEntityBase parent) {
		this.parent = parent;
	}

}
